home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-09-14 | 6.0 KB | 231 lines | [TEXT/MPS ] |
- #
- # File: AddChange
- #
- # Contains: script to add changes to a window
- #
- # Usage: AddChange window [version [commentFile]]
- #
- # Status: AddChange may return the following status values:
- #
- # 0 the change was added
- # 1 error
- # 2 the user canceled
- #
- # AddChange adds a change from the file, commentFile, to the window.
- # The change is inserted after the Change History text. If no change history
- # is found, a dialog is presented, allowing the user to add a blank header
- # to the file. If no commentFile is passed, the comment field is left blank.
- # The mark character is used to mark the change.
- #
- # Written by: Darin Adler and scott douglass
- #
- # Copyright: © 1988-1990 by Apple Computer, Inc., all rights reserved.
- #
- # Change History (maintain by hand, AddChange confuses itself by editing itself):
- #
- # 2/9/90 ags removed EASE header conversion
- # 1/23/90 dba put in tweaks for Finder (1990 and old Change Histories)
- # 12/28/89 dba don’t put the user name in Written By:
- # 12/27/89 dba added a case for .aii
- # 12/19/89 dba fixed the .a and .p cases (fixed in BBS by Jeff Miller)
- # 12/18/89 dba made it work with upper-case extensions
- # 12/11/89 dba made it work with new headers
- # 11/17/89 dba use WrapCommentText
- # 11/9/89 dba stopped using LastChange marker; invented mark character
- #
- # To Do:
- #
-
- Set CaseSensitive 0
- Set Exit 0
-
- # the following helps to debug until MPW sends echos to Dev:Console instead of Dev:StdErr
-
- If {Echo}
- Set somewhere "∑∑ '{Worksheet}'"
- Else
- Set somewhere "∑ Dev:Null"
- End
-
- Begin
-
- Set Window "{1}" # add change to this file (must be open window)
- Set Version "{2}" # use this version
- Set Comment "{3}" # get comment from this file (should not be open)
-
- # add <> to version number
-
- If "{Version}" != ""
- If "{Version}" =~ /[¬∂[<]≈/
- Set Version "<{Version}>"
- End
- End
-
- # get rid of obsolete marker
-
- Unmark LastChange "{Window}"
-
- # get short name of window
-
- If "{Window}" =~ /:*([¬:]+:*)*([¬:]+.([a-z]+)®2)®1/
- Set Short "{®1}"
- Set Suffix {®2}
- Else If "{Window}" =~ /:*([¬:]+:*)*([¬:]+)®1/
- Set Short "{®1}"
- Set Suffix ""
- Else
- Exit 1
- End
-
- If "{Suffix}" =~ /[chri]/ # comments for C, C headers, Rez, and .i files (used in Finder)
- Set StartComment '/*'
- Set EndComment '*/'
- Set Leader ''
- Else If "{Suffix}" =~ /cp/ # comments for C++
- Set StartComment '/*'
- Set EndComment '*/'
- Set Leader ''
- Else If "{Suffix}" =~ /p/ # comments for Pascal
- Set StartComment '{'
- Set EndComment '}'
- Set Leader ''
- Else If "{Suffix}" =~ /a/ # comments for assembly language
- Set StartComment ';'
- Set EndComment ';'
- Set Leader ';'
- Else If "{Suffix}" =~ /aii/ # comments for 6502 assembly language
- Set StartComment ';'
- Set EndComment ';'
- Set Leader ';'
- Else # comments for shell scripts, Makefiles etc.
- Set StartComment '#'
- Set EndComment '#'
- Set Leader '#'
- End
-
- # fix an 80’s date to be 1990 (won’t work next year)
-
- Find • "{Window}"
- Replace /© (198[0-9])®1(≈198[0-9])«0,1» by/ '© ®1-1990 by' "{Window}"
-
- # find a change history
-
- Set Found 0
-
- Find • "{Window}"
- Find /Change History ∂(most recent first∂):[ ∂t]*∂n{Leader}[ ∂t]*∂n/Δ "{Window}" && Set Found 1
- If !{Found}
- Replace /(Change History ∂(most recent first∂):[ ∂t]*∂n)/ ∂
- "®1{Leader}∂n" "{Window}" && Set Found 1
- End
-
- # if no change history was found, look for a Finder header
-
- If !{Found}
- Replace /Change History:([ ∂t]*∂n{Leader}[ ∂t]*∂n)®1/ ∂
- 'Change History (most recent first):®1' "{Window}" && Set Found 1
- End
- If !{Found}
- Replace /Change History:([ ∂t]*∂n)®1/ ∂
- "Change History (most recent first):®1{Leader}∂n" "{Window}" && Set Found 1
- End
-
- # if we still haven’t found a change history, offer to add a new one
-
- If !{Found}
- If "{Comment}" ≠ ""
- Confirm -t "I can’t find a change history in “{Short}”. Do you want to add a header?"
- Set ConfirmStatus {Status}
- If {ConfirmStatus} == 5 # cancel: report this to the caller
- Exit 2
- Else If {ConfirmStatus} == 4 # no: don’t add the change
- Exit
- End # yes: go on with life as usual
- End
-
- If "{Contents}" == ""
- Set Contents "xxx put contents here xxx"
- End
-
- If "{Writers}" == ""
- Set Writers "xxx put writers here xxx"
- End
-
- If "{Copyright}" == ""
- If "`Date -a -d`" =~ /≈, (19[0-9][0-9])®1/
- Set Copyright "© {®1} by Apple Computer, Inc., all rights reserved."
- End
- End
-
- Find • "{Window}"
- Begin
- Echo "{StartComment}"
- Echo "{Leader}∂tFile:∂t∂t{Short}"
- Echo "{Leader}"
- Echo "{Leader}∂tContains:∂t{Contents}"
- Echo "{Leader}"
- Echo "{Leader}∂tWritten by:∂t{Writers}"
- Echo "{Leader}"
- Echo "{Leader}∂tCopyright:∂t{Copyright}"
- Echo "{Leader}"
- Echo "{Leader}∂tChange History (most recent first):"
- Echo "{Leader}"
- Echo "{Leader}"
- Echo "{Leader}∂tTo Do:"
- Echo "{EndComment}"
- Echo
- End > "{Window}.§"
- Find !0 "{Window}"
- Find Δ¡3 "{Window}"
- End
-
- # concoct the change line for the change history
-
- If "{Version}" == ""
- Set Version ∂t∂t
- Else
- If "{Version}" =~ /?«5,»/
- If " {Version}" =~ /≈(????????)®1/
- Set Version "{®1}"
- End
- Else
- If " {Version}" =~ /≈(????)®1/
- Set Version "∂t{®1}"
- End
- End
- End
-
- If " `Date -d -s`" =~ /≈(????????)®1/
- Set ChangeDate "{®1}"
- Else
- Set ChangeDate "??/??/??"
- End
-
- If "{UserInitials}" == "" # no initials, use user name instead
- Set UserInitials "" # in case it was not defined before
- Set TrimmingName "{User}" # use this for the loop
- Loop
- If "{TrimmingName}" =~ /([a-z])®1[a-z.]* (≈)®2/
- Set UserInitials {UserInitials}{®1}
- Set TrimmingName "{®2}"
- Else If "{TrimmingName}" =~ /([a-z])®1[a-z.]*/
- Set UserInitials {UserInitials}{®1}
- Break
- Else
- Set UserInitials "{User}∂n∂t∂t∂t∂t∂t∂t∂t"
- Break
- End
- End
- End
-
- # put the comment at the top of the change history
-
- Begin
- Echo -n "{Leader}∂t{Version}∂t{ChangeDate}∂t{UserInitials}∂t∂t"
- WrapCommentText 65 "{Leader}∂t∂t∂t∂t∂t∂t∂t∂t∂t" < "{Comment}" || ∂
- Echo -n "xxx put comment here xxx"
- Echo
- End > "{Window}.§"
-
- End {somewhere}
-